/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Chien
 */
@Entity
@Table(name = "TBL_REGISTRATION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Registration.findAll", query = "SELECT r FROM Registration r"),
    @NamedQuery(name = "Registration.findByRegId", query = "SELECT r FROM Registration r WHERE r.regId = :regId"),
    @NamedQuery(name = "Registration.findByRegDate", query = "SELECT r FROM Registration r WHERE r.regDate = :regDate"),
    @NamedQuery(name = "Registration.findByCancelDate", query = "SELECT r FROM Registration r WHERE r.cancelDate = :cancelDate"),
    @NamedQuery(name = "Registration.findByJoinedStatus", query = "SELECT r FROM Registration r WHERE r.joinedStatus = :joinedStatus"),
    @NamedQuery(name = "Registration.findByIsAcceped", query = "SELECT r FROM Registration r WHERE r.isAcceped = :isAcceped")})
public class Registration implements Serializable {
    @Column(name =     "RegDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date regDate;
    @Column(name =     "CancelDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date cancelDate;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "RegId")
    private String regId;
    @Column(name = "JoinedStatus")
    private Boolean joinedStatus;
    @Column(name = "isAcceped")
    private Boolean isAcceped;
    @OneToMany(mappedBy = "regId")
    private List<Winner> winnerList;
    @JoinColumn(name = "UserName", referencedColumnName = "UserName")
    @ManyToOne(optional = false)
    private User userName;
    @JoinColumn(name = "EventId", referencedColumnName = "EventId")
    @ManyToOne(optional = false)
    private Event eventId;

    public Registration() {
    }

    public Registration(String regId) {
        this.regId = regId;
    }

    public String getRegId() {
        return regId;
    }

    public void setRegId(String regId) {
        this.regId = regId;
    }

    public Boolean getJoinedStatus() {
        return joinedStatus;
    }

    public void setJoinedStatus(Boolean joinedStatus) {
        this.joinedStatus = joinedStatus;
    }

    public Boolean getIsAcceped() {
        return isAcceped;
    }

    public void setIsAcceped(Boolean isAcceped) {
        this.isAcceped = isAcceped;
    }

    @XmlTransient
    public List<Winner> getWinnerList() {
        return winnerList;
    }

    public void setWinnerList(List<Winner> winnerList) {
        this.winnerList = winnerList;
    }

    public User getUserName() {
        return userName;
    }

    public void setUserName(User userName) {
        this.userName = userName;
    }

    public Event getEventId() {
        return eventId;
    }

    public void setEventId(Event eventId) {
        this.eventId = eventId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (regId != null ? regId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Registration)) {
            return false;
        }
        Registration other = (Registration) object;
        if ((this.regId == null && other.regId != null) || (this.regId != null && !this.regId.equals(other.regId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Registration[ regId=" + regId + " ]";
    }

    public Date getRegDate() {
        return regDate;
    }

    public void setRegDate(Date regDate) {
        this.regDate = regDate;
    }

    public Date getCancelDate() {
        return cancelDate;
    }

    public void setCancelDate(Date cancelDate) {
        this.cancelDate = cancelDate;
    }
    
}
